import uvicorn
from mcp.server.fastmcp import FastMCP
from starlette.applications import Starlette
from starlette.routing import Mount

from application.base_mcp_v1.block_type_mcp_tool import block_type_tool
from application.base_mcp_v1.excel_mcp_tool import excel_to_json_array_tool
from application.base_mcp_v1.family_bucket_mcp_tool import family_bucket_tool
from application.base_mcp_v1.interface_implementer_mcp_tool import interface_implementer_tool
from application.base_mcp_v1.tqt_base_coding_mcp_prompt import entity_go_prompt, value_go_prompt, parser_go_prompt, \
    validate_go_prompt
from application.base_mcp_v1.value_code_template_mcp_tool import value_code_template_tool

mcp_server = FastMCP(
    name='tqt-activity-development-basic-mcp-server-vk-v1',
)
# 提示词工具
mcp_server.add_tool(
    fn=entity_go_prompt,
    name='entity.go编码提示词',
    description='entity.go编码提示词'
)

mcp_server.add_tool(
    fn=value_go_prompt,
    name='value.go编码提示词',
    description='value.go编码提示词'
)

mcp_server.add_tool(
    fn=parser_go_prompt,
    name='parser.go编码提示词',
    description='parser.go编码提示词'
)

mcp_server.add_tool(
    fn=validate_go_prompt,
    name='validate.go编码提示词',
    description='validate.go编码提示词'
)

# 开发工具
mcp_server.add_tool(
    fn=excel_to_json_array_tool,
    name='excel转JSON工具',
    description='将excel表格数据转换为JSON二维数组'
)
# mcp_server.add_tool(
#     fn=excel_to_struct_tool,
#     name='excel转结构体工具',
#     description='传入excel表格将自动推导配置项是否可复用全家桶并返回结果'
# )
mcp_server.add_tool(
    fn=block_type_tool,
    name='排期工具'
    , description='按排期类型决定使用对应的block'
)
mcp_server.add_tool(
    fn=interface_implementer_tool,
    name='接口工具',
    description='提供接口名称，将返回需要接口定义信息'
)
mcp_server.add_tool(
    fn=value_code_template_tool,
    name='value代码生成工具',
    description='将用户提供的活动信息生成value.go代码'
)
mcp_server.add_tool(
    fn=family_bucket_tool,
    name='全家桶工具',
    description='传入单个配置项JSON二维数组可确认是否可复用全家桶配置项'
)

app = Starlette(
    routes=[
        Mount('/', app=mcp_server.sse_app()),
    ]
)

if __name__ == '__main__':
    uvicorn.run(app, host='127.0.0.1', port=8000)
